package com.ruoyi.peoplegroup.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.peoplegroup.domain.ResearcherinfoHistory;
import com.ruoyi.peoplegroup.service.IResearcherinfoHistoryService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 科研人员信息历史跟踪Controller
 *
 * @author lh
 * @date 2025-01-16
 */
@RestController
@RequestMapping("/history")
public class ResearcherinfoHistoryController extends BaseController {
    @Autowired
    private IResearcherinfoHistoryService researcherinfoHistoryService;

    /**
     * 查询科研人员信息历史跟踪列表
     */
    @RequiresPermissions("peoplegroup:history:list")
    @GetMapping("/list")
    public TableDataInfo list(ResearcherinfoHistory researcherinfoHistory) {
        startPage();
        List<ResearcherinfoHistory> list = researcherinfoHistoryService.selectResearcherinfoHistoryList(researcherinfoHistory);
        return getDataTable(list);
    }

    /**
     * 导出科研人员信息历史跟踪列表
     */
    @RequiresPermissions("peoplegroup:history:export")
    @Log(title = "科研人员信息历史跟踪", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ResearcherinfoHistory researcherinfoHistory) {
        List<ResearcherinfoHistory> list = researcherinfoHistoryService.selectResearcherinfoHistoryList(researcherinfoHistory);
        ExcelUtil<ResearcherinfoHistory> util = new ExcelUtil<ResearcherinfoHistory>(ResearcherinfoHistory.class);
        util.exportExcel(response, list, "科研人员信息历史跟踪数据");
    }

    /**
     * 获取科研人员信息历史跟踪详细信息
     */
    @RequiresPermissions("peoplegroup:history:query")
    @GetMapping(value = "/{researcherinfoHistoryId}")
    public AjaxResult getInfo(@PathVariable("researcherinfoHistoryId") Long researcherinfoHistoryId) {
        return success(researcherinfoHistoryService.selectResearcherinfoHistoryByResearcherinfoHistoryId(researcherinfoHistoryId));
    }

    /**
     * 新增科研人员信息历史跟踪
     */
    @RequiresPermissions("peoplegroup:history:add")
    @Log(title = "科研人员信息历史跟踪", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ResearcherinfoHistory researcherinfoHistory) {
        return toAjax(researcherinfoHistoryService.insertResearcherinfoHistory(researcherinfoHistory));
    }

    /**
     * 修改科研人员信息历史跟踪
     */
    @RequiresPermissions("peoplegroup:history:edit")
    @Log(title = "科研人员信息历史跟踪", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ResearcherinfoHistory researcherinfoHistory) {
        return toAjax(researcherinfoHistoryService.updateResearcherinfoHistory(researcherinfoHistory));
    }

    /**
     * 删除科研人员信息历史跟踪
     */
    @RequiresPermissions("peoplegroup:history:remove")
    @Log(title = "科研人员信息历史跟踪", businessType = BusinessType.DELETE)
    @DeleteMapping("/{researcherinfoHistoryIds}")
    public AjaxResult remove(@PathVariable Long[] researcherinfoHistoryIds) {
        return toAjax(researcherinfoHistoryService.deleteResearcherinfoHistoryByResearcherinfoHistoryIds(researcherinfoHistoryIds));
    }
    @RequiresPermissions("peoplegroup:researcherinfo:history")
    @GetMapping(value = "/history/{researcherId}")
    public AjaxResult getresearcherhistoryInfo(@PathVariable("researcherId") Long researcherId) {
        return success(researcherinfoHistoryService.selectResearcherinfoHistoryByresearcherId(researcherId));
    }

    
}
